set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set incsearch    " 查询时非常方便，如要查找book单词，当输入到/b时，会自动找到
set nu! 
set is            "搜索时没有收入完就搜索
set et            "将tab换成空格

colorscheme desert 
syntax enable 
syntax on
colo torte         "设置配色方案

set autoindent     "自动对齐  
set cindent  
set smartindent    "智能选择对齐方式  
let g:neocomplcache_enable_at_startup = 1 "插件自动启动




"括号自动补全
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {<CR>}<ESC>O
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
function ClosePair(char) 
        if getline('.')[col('.') - 1] == a:char
                return "\<Right>"
        else 
                return a:char 
        endif
endf




set guioptions-=m  "全屏
set guioptions-=T

set shiftwidth=2   "设置自动缩进 2 个空格
set sts=2          "即设置 softtabstop 为 4. 输入 tab 后就跳了 4 格
set tabstop=2      "实际的 tab 即为 4 个空格, 而不是缺省的 8 个
set expandtab      "在输入 tab 后, vim 用恰当的空格来填充这个 tab
filetype pluginindenton       " 加了这句才可以用智能补全
set showmatch       " 设置匹配模式，类似当输入一个左括号时会匹配相应的那个右括号

"set guifont=courier_new:h10

set sm 				"显示括号的配对情况。
set cin 		    "打开 C/C++ 风格的自动缩进
set wildmenu        "在命令模式下使用 Tab 自动补全的时候， 将补全内容使用一个漂亮的单行菜单形式显示出来。

set diffexpr=MyDiff()
function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let eq = ''
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      let cmd = '""' . $VIMRUNTIME . '\diff"'
      let eq = '"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction




"""""""""""""""""""""""
"--ctags setting--
"""""""""""""""""""""""
" 按下F12重新生成tag文件，并更新taglist
map <F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR> :TlistUpdate<CR>
imap <F12> <ESC>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR> :TlistUpdate<CR>
set tags=tags;
"set autochdir 
set tags+=.\tags "add current directory's generated tags file
set tags+=..\tags "add current directory's generated tags file
set tags+=*.\tags "add current directory's generated tags file
"set tags+=E:\code\SmartLock_V4\smartlock2\tags "add new tags file(刚刚生成tags的路径，在ctags -R 



"""""""""""""""""""""""""""""""""""""""""""""""""""
"Taglist
"""""""""""""""""""""""""""""""""""""""""""""""""""
let Tlist_Show_Menu=1
"let Tlist_Ctags_Cmd='D:\ctags58\ctags.exe'”这句话可有可无，但我还是加了，以防万一
let Tlist_Auto_Open=1				   "启动vim自动打开taglist
let Tlist_File_Fold_Auto_Close=1	   "让当前不被编辑的文件的方法列表自动折叠起来 
let Tlist_Compact_Format=1
let Tlist_Enable_Fold_Column=1				

filetype plugin on

let Tlist_Display_Prototype = 1
let Tlist_Sort_Type = "order"          "使taglist以tag名字进行排序
let Tlist_Show_One_File = 1            "不同时显示多个文件的tag，只显示当前文件的
let Tlist_Exit_OnlyWindow = 1          "如果taglist窗口是最后一个窗口，则退出vim
let Tlist_Use_Right_Window = 1         "在右侧窗口中显示taglist窗口
let Tlist_Use_SingleClick = 1          "单击tag就跳转到定义
let Tlist_GainFocus_On_ToggleOpen = 1  "使用:TlistToggle打开taglist窗口时，输入焦点在taglist窗口中
nmap <silent> <F9> :TlistToggle<CR>    "打开tag窗口，这个是设置快捷键





""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""winmanager 窗口管理
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"let g:winManagerWindowLayout='FileExplorer|TagList' 
let g:winManagerWindowLayout='FileExplorer' 

nmap wm :WMToggle<cr> 	"输入wm打开窗口
set ai 					"设置自动缩进
set cindent 			"设置使用 C/C++ 语言的自动缩进方式



""""""""""""""""""""""""""""""""""""""""""""""
""omni completion 
""""""""""""""""""""""""""""""""""""""""""""""
" 自动关闭补全窗口 
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif 
"set completeopt=menuone,menu,longest

highlight Pmenu    guibg=darkgrey  guifg=black 
highlight PmenuSel guibg=lightgrey guifg=black

"-- omnicppcomplete setting --
" 按下F3自动补全代码，注意该映射语句后不能有其他字符，包括tab；否则按下F3会自动补全一些乱码
imap <F3> <C-X><C-O>
" 按下F2根据头文件内关键字补全
imap <F2> <C-X><C-I>
set completeopt=menu,menuone,longest	    " 关掉智能补全时的预览窗口
let OmniCpp_MayCompleteDot = 1 				" autocomplete with .
let OmniCpp_MayCompleteArrow = 1 			" autocomplete with ->
let OmniCpp_MayCompleteScope = 1 			" autocomplete with ::
let OmniCpp_SelectFirstItem = 2 			" 自动弹出时自动跳至第一个
let OmniCpp_NamespaceSearch = 2 			" search namespaces in this and included files
let OmniCpp_ShowPrototypeInAbbr = 1 		" 是否是补全提示缩略信息中显示函数原型。
let OmniCpp_GlobalScopeSearch=1 			" enable the global scope search
let OmniCpp_DisplayMode=1 					" 类成员显示控制(是否显示全部公有(public)私有(private)保护(protected)成员)。0 自动 1全部显示
"let OmniCpp_DefaultNamespaces=["std"]
let OmniCpp_ShowScopeInAbbr=1 " show scope in abbreviation and remove the last column
let OmniCpp_ShowAccess=1 
let OmniCpp_LocalSearchDecl = 1 

"set tags+=E:/code/SmartLock_V4/smartlock2/tags " OmniCppComplete






"""""""""""""""""""""""""""""""""""""""""""""
"多窗口文档配置  minibufexpl.vim 
"""""""""""""""""""""""""""""""""""""""""""""
let g:miniBufExplMapCTabSwitchBufs=1 
let g:miniBufExplMapWindowsNavVim=1 
let g:miniBufExplMapWindowNavArrows=1 
let g:miniBufExplMapWindowNavArrows=1
let g:miniBufExplorerMoreThanOne=0
nnoremap <silent> <F11> :A<CR> 
nnoremap <silent> <F5> :Grep<CR>“快速查找



"""""""""""""""""""""""""""""""""""""""""""""
" 配置多语言环境,解决中文乱码问题
"""""""""""""""""""""""""""""""""""""""""""""
if has("multi_byte") 
    " UTF-8 编码 
    set encoding=utf-8 
    set termencoding=utf-8 
    set formatoptions+=mM 
    set fencs=utf-8,gbk 
    if v:lang =~? '^/(zh/)/|/(ja/)/|/(ko/)' 
        set ambiwidth=double 
    endif 
    if has("win32") 
        source $VIMRUNTIME/delmenu.vim 
        source $VIMRUNTIME/menu.vim 
        language messages zh_CN.utf-8 
    endif 
else 
    echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte" 
endif

let g:SuperTabRetainCompletionType = 2
let g:SuperTabDefaultCompletionType = "<C-X><C-O>" 

filetype plugin indent on 
set nocp
filetype plugin on 

autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete

"-----------------------------------------------------------------

" plugin - NERD_commenter.vim   注释代码用的，
" [count],cc 光标以下count行逐行添加注释(7,cc)
" [count],cu 光标以下count行逐行取消注释(7,cu)
" [count],cm 光标以下count行尝试添加块注释(7,cm)
" ,cA 在行尾插入 /* */,并且进入插入模式。这个命令方便写注释。
" 注：count参数可选，无则默认为选中行或当前行
"-----------------------------------------------------------------
let NERDShutUp=1
let NERDSpaceDelims=1       " 让注释符与语句之间留一个空格
let NERDCompactSexyComs=1   " 多行注释时样子更好看



" 注释函数
map dox :Dox<cr>			
" 注释文档
map doa :DoxAuthor<cr>		
" 注释版权
map dol :DoxLic				
" 标准注释插件配置
let g:DoxygenToolkit_authorName="Fighter"
let g:DoxygenToolkit_licenseTag="My own license\<enter>"
let g:DoxygenToolkit_undocTag="DOXIGEN_SKIP_BLOCK"
" let g:DoxygenToolkit_blockHeader="----------------------------------------------------------------------------"
" let g:DoxygenToolkit_blockFooter="----------------------------------------------------------------------------"
let g:DoxygenToolkit_briefTag_pre = "@brief\t"
let g:DoxygenToolkit_paramTag_pre = "@param\t"
let g:DoxygenToolkit_returnTag = "@return\t"
let g:DoxygenToolkit_briefTag_funcName = "yes"
let g:DoxygenToolkit_maxFunctionProtoLines = 30
let g:doxygen_enhanced_color=1


"let g:clang_complete_copen=1
"let g:clang_periodic_quickfix=1
"let g:clang_snippets=1
"let g:clang_close_preview=1
"let g:clang_use_library=1
"let g:clang_user_options='-stdlib=libc++ -std=c++11 -IIncludePath'
" 禁用补全时的预览窗口
"set completeopt-=preview
 

